home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / datasheets and manuals / Hardware / WHT / scsi / dsr_sources_2_2001 / delete < prev    next >
Text File  |  2006-10-19  |  5KB  |  199 lines

  1. ************************************************************
  2. *                                                          *
  3. * DELETE                                                   *
  4. *                                                          *
  5. * This routine will delete the file specified in the       *
  6. * name compare buffer.  If the file is open, it will       *
  7. * be closed before deleting the file.                      *
  8. *                                                          *
  9. * The following steps are taken.                           *
  10. *  - Check that the file exists                            *
  11. *  - Check that the file is not protected                  *
  12. *  - Remove the entry from the directory and               *
  13. *    decrement the number of file in the directory         *
  14. *  - Deallocate all AUs associated with the file.          *
  15. *                                                          *
  16. ************************************************************
  17.  
  18. DEL0   ANDI R12,>FF00
  19.        AI   R12,24
  20.        LDCR @B02,4       Select RAM bank 2
  21.  
  22. * First check to see if the file is open
  23. *
  24.        BLWP @IFO
  25.        JNE  DELE20
  26.  
  27. * OK, the file is open.  See if it has the protection bit set
  28. *
  29.        MOVB @2(R5),R7    Get bank where FDR is stored
  30.        MOV  @4(R5),R8    Get address of FDR
  31.        MOV  @48(R5),R4   Get AU of FDR
  32.        CLR  @2(R5)       Close the file
  33.        MOV  R8,R5
  34.        JMP  DELE21
  35. *      LDCR R7,4             Select RAM bank where FDR is located
  36. *      MOV  @12(R8),R0       Get file flags
  37. *      COC  @PROBIT,R0       Check to see if file is protected
  38. *      JEQ  DELPRO
  39. *
  40. *      LDCR @B02,4       Select bank 2 again
  41. *      CLR  @2(R5)       Close the file
  42. *      MOV  @48(R5),R0   Save AU of FDR
  43. *
  44. * Copy the FDR to the buffer
  45. *
  46. *      LI   R2,DFDR
  47. *      LI   R3,256
  48. *DELE2  LDCR R7,4
  49. *      MOV  *R8+,R4
  50. *      LDCR @B02,4       Select RAM bank 2
  51. *      MOV  R4,*R2+
  52. *      DECT R3
  53. *      JNE  DELE2
  54. *
  55. *      MOV  R0,@DFDR     Put AU in the delete buffer
  56. *      B    @DELE50
  57. *
  58. *
  59. * DELPRO - Here is where we error out if we're trying
  60. *          to delete a file that is protected
  61. *
  62.  
  63. DELPRO BL   @DSRERR
  64.        DATA >0100            File is protected
  65.  
  66. * We branch to here if the file is not open
  67. *
  68. DELE20 BL   @GETFDR          See if the file exists
  69.        CI   R5,0
  70.        JEQ  DELERR
  71.        CLR  R7               Bank where FDR is
  72.        LDCR @B04,4
  73.        MOV  @SAVEAU,R4       Get AU of FDR
  74.  
  75. * See if the file is protected
  76. *
  77. DELE21 LDCR R7,4
  78.        MOV  @12(R5),R0        Get file flags
  79.        COC  @PROBIT,R0
  80.        JEQ  DELPRO
  81.  
  82. * Copy the FDR to DFDR and store the AU of the FDR in the
  83. * first word.
  84. *
  85.        LDCR @B02,4       Save AU of the FDR
  86.        MOV  R4,@DFDR
  87.  
  88. DELE22 AI   R5,40        Point to data chain
  89.        LI   R0,216       216 bytes of data chain pointers
  90.        LI   R1,DFDR+40
  91. DELE23 LDCR R7,4         Select RAM bank 0
  92.        MOV  *R5+,R2
  93.        LDCR @B02,4       Select RAM bank 2
  94.        MOV  R2,*R1+
  95.        DECT R0
  96.        JNE  DELE23
  97. *      JMP  DELE50
  98.  
  99. * Now that we have the Delete FDR (DFDR) buffer all set up,
  100. * delete the actual file
  101. *
  102. *DELE50
  103. * Step 1: Decrement the number of files in the directory
  104. *
  105.        BL   @GETDDR
  106.        CI   R5,0         This shouldn't happen, but check anyway
  107.        JEQ  DELERR
  108.        MOV  @SAVEAU,R7   Get AU of the parent directory
  109.        MOV  R6,R3
  110.        SRL  R3,8
  111.        SLA  R3,1
  112.        MPY  @SAUTBL(R3),R7
  113.        LI   R4,SECBUF
  114.        SRL  R8,1
  115.        JNC  DELE51
  116.        AI   R4,>100
  117. DELE51 SRL  R7,1
  118.        JNC  DELE52
  119.        AI   R8,>8000
  120. DELE52 LDCR @ZERO,4
  121.        BLWP @BANKIT
  122.        DATA SCSIRD
  123.        JNE  DELERR
  124.        SB   @B01,@22(R4)     Decrement # of files
  125.        BLWP @BANKIT          Write DDR back out
  126.        DATA SCSIWT
  127.        JNE  DELERR
  128.  
  129. * Now decrement the number in the cache
  130. *
  131.        LDCR @B03,4
  132.        SB   @B01,@22(R5)
  133.  
  134. * Step 2: Remove AU of the FDR from the index
  135. *
  136.        MOV  @24(R5),R7
  137.        LDCR @B04,4       Select RAM bank 4
  138.        MPY  @SAUTBL(R3),R7
  139.        LI   R4,SECBUF
  140.        SRL  R8,1
  141.        JNC  DELE53
  142.        AI   R4,>100
  143. DELE53 SRL  R7,1
  144.        JNC  DELE54
  145.        AI   R8,>8000
  146. DELE54 LDCR @ZERO,4
  147.        BLWP @BANKIT
  148.        DATA SCSIRD
  149.        JNE  DELERR
  150.  
  151.        LDCR @B02,4       Select RAM bank 2
  152.        MOV  @DFDR,R5     Get AU of the FDR
  153.        LDCR @ZERO,4      Select RAM bank 0
  154.  
  155. DELE55 C    *R4+,R5      Is this the AU we're looking for?
  156.        JEQ  DELE56
  157.        CI   R4,>5EFE
  158.        JEQ  DELERR
  159.        CI   R4,>5FFE
  160.        JNE  DELE55
  161. *      JMP  DELE55
  162.  
  163. DELERR BL   @DSRERR
  164.        DATA >0700        File error
  165. DELE56 CI   R4,>5EFE     Do we need to move any more down?
  166.        JEQ  DELE57
  167.        CI   R4,>5FFE
  168.        JEQ  DELE57
  169.        MOV  *R4,@-2(R4)
  170.        INCT R4
  171.        JMP  DELE56
  172.  
  173. DELE57 CLR  @-2(R4)
  174.        BLWP @BANKIT      Write index back out to disk
  175.        DATA SCSIWT
  176.        JNE  DELERR
  177.  
  178. * Now deallocate all AU's the file had used
  179. *
  180.        LDCR @B02,4       Select RAM bank 2
  181.        MOV  @DFDR,R7     Get AU that FDR used to be in
  182.        MOV  R7,R8
  183.        LDCR @ZERO,4      Select RAM bank 0
  184.        BLWP @DEALL
  185.  
  186.        LI   R4,DFDR+40
  187.  
  188. DELE58 LDCR @B02,4       Select RAM bank 2
  189.        MOV  *R4+,R7
  190.        JEQ  DELE59
  191.        MOV  *R4+,R8
  192.        LDCR @ZERO,4      Select RAM bank 0
  193.        BLWP @DEALL
  194.        CI   R4,DFDR+254  Are we done?
  195.        JNE  DELE58
  196.  
  197. DELE59 LDCR @ZERO,4
  198.        B    @DSRRT
  199.